package model.network

import model.network.api.ChannelMappingService
import model.network.api.UserService
import model.network.interceptor.RequestInterceptor
import okhttp3.OkHttpClient
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

object Network {
    private val BASE_URL = "http://localhost:9527"
    private val okHttpClient = OkHttpClient.Builder()
        .callTimeout(30, TimeUnit.SECONDS)
        .addInterceptor(RequestInterceptor())//请求拦截器
        .build()

    private val retrofit = retrofit2.Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .client(okHttpClient)
        .build()

    val userService: UserService = retrofit.create(UserService::class.java)
    val channelMappingService: ChannelMappingService = retrofit.create(ChannelMappingService::class.java)
}